﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using System.Data;

namespace DAL
{
   public class CommodityDAL
    {
        DBHelper db = new DBHelper();
        public List<Commodity> auctions()
        {
            string sqlShow = "select CommodityID, CommodityCategory from[dbo].[Commodity]";
            List<Commodity> list = null;
            DataTable dt = db.GetData(sqlShow);
            if (dt.Rows.Count > 0)
            {
                list = new List<Commodity>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Commodity ac = new Commodity();
                    ac.CommodityID = Convert.ToInt32(dt.Rows[i]["CommodityID"]);
                    ac.CommodityCategory = dt.Rows[i]["CommodityCategory"].ToString();
                    list.Add(ac);
                }
            }
            return list;

        }
    }
}
